﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp1
{
    public class CodeNode : ObservableObject
    {
        public Code Code { get; set; }
        public string Name { get; set; }

        public string GetParent
        {
            get
            {
                if (string.IsNullOrWhiteSpace(Code?.关键字) || !Code.关键字.Contains("\\"))
                {
                    return null;
                }
                else
                {
                    return Code.关键字.Substring(0, Code.关键字.LastIndexOf('\\'));
                }
            }
        }

        public CodeNode(Code Code)
        {
            this.Code = Code;
            Name = Path.GetFileName(Code.关键字);
        }

        public List<CodeNode> Items { get; set; } = new List<CodeNode>();
    }
}